import time


def is_exist(employNo,employee_records:dict):
    if employNo in employee_records:
        return True
    else:
        return False



def employee_query(employNo,employee_records:dict):
    if employNo in employee_records:
        print(employee_records[employNo])
    else:
        print('查无此人')

def employee_insert(employNo,name,age,position,employee_records:dict):
    exist = is_exist(employNo, employee_records)
    if exist:
        print('此工号用户已经存在')
    else:
        print('新增员工信息中.....')
        employee_records[employNo] = {'name':name,'age':age,'position':position}
        time.sleep(2)
        print('插入员工信息成功!')

def employee_del(employNo, employee_records:dict):
    exist = is_exist(employNo, employee_records)
    if exist:
        del employee_records[employNo]
        print('删除成功')
    else:
        print('没有这个人啊,怎么删除呀?')


if __name__ == '__main__':
    employee_records = {'1001':{'name':'Alice','age':'25','position':'Manager'},'1002':{'name':'Bob','age':30,'position':'Engineer'}}
    # print(type(employee_records))
    while True:
        print('欢迎来到oa系统:请选择你需要的功能:')
        print('1.查询员工')
        print('2.增加员工')
        print('3.删除员工')
        print('4.退出系统')
        int_employee = int(input('请输入你需要的业务功能'))
        if int_employee == 1:
            employee_no = input("请输入你要查询的员工工号:")
            employee_query(employee_no,employee_records)
        elif int_employee == 2:
            employee_no = input("请输入你需要增加员工的工号:")
            if is_exist(employee_no,employee_records):
                print("此员工已经存在了啊!")
                continue
            else:
                employee_name = input("请输入你需要增加员工的姓名:")
                employee_age = input("请输入你需要增加员工的年龄:")
                employee_pos = input("请输入你需要增加员工的职位:")
                employee_insert(employee_no,employee_name,employee_age,employee_pos,employee_records)
        elif int_employee == 3:
            employee_no = input("请输入你需要删除员工的工号:")
            employee_del(employee_no, employee_records)
        elif int_employee == 4:
            break